| Full Name | Team | Position | college | awareness_rating | throwPower_rating | kickReturn_rating | leadBlock_rating | strength_rating | bCVision_rating | catchInTraffic_rating | playAction_rating | pursuit_rating | plyrAssetname | mediumRouteRunning_rating | catching_rating | acceleration_rating | spinMove_rating | height | finesseMoves_rating | spectacularCatch_rating | runBlock_rating | tackle_rating | injury_rating | zoneCoverage_rating | weight | plyrBirthdate | runningStyle_rating | deepRouteRunning_rating | firstName | yearsPro | totalSalary | trucking_rating | throwAccuracyShort_rating | position | jukeMove_rating | playRecognition_rating | shortRouteRunning_rating | status | lastName | jerseyNum | breakSack_rating | speed_rating | runBlockPower_rating | jumping_rating | toughness_rating | throwOnTheRun_rating | manCoverage_rating | stiffArm_rating | powerMoves_rating | iteration | release_rating | hitPower_rating | throwAccuracyMid_rating | kickAccuracy_rating | passBlockPower_rating | impactBlocking_rating | stamina_rating | carrying_rating | breakTackle_rating | plyrPortrait | kickPower_rating | plyrHandedness | throwUnderPressure_rating | team | signingBonus | passBlock_rating | changeOfDirection_rating | press_rating | throwAccuracyDeep_rating | archetype | blockShedding_rating | runBlockFinesse_rating | teamId | agility_rating | fullNameForSearch | overall_rating | passBlockFinesse_rating | age | primaryKey |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Aaron Donald | Rams | RE | Pittsburgh | 99 | 20 | 10 | 23 | 99 | 49 | 23 | 6 | 98 | DonaldAaron_10852 | 9 | 42 | 90 | 25 | 73 | 97 | 47 | 45 | 93 | 98 | 29 | 280 | ######## | Default Stride Loose | 5 | Aaron | 8 | 41670000 | 32 | 6 | RE | 28 | 99 | 16 | published | Donald | 99 | 12 | 82 | 45 | 78 | 97 | 6 | 25 | 30 | 99 | launch-ratings | 12 | 89 | 6 | 21 | 45 | 93 | 88 | 48 | 17 | 6394 | 25 | Right | 15 | Rams | 45500000 | 45 | 68 | 21 | 6 | DE_PowerRusher | 97 | 45 | 24 | 86 | Aaron Donald | 99 | 45 | 31 | 10852 |
| Davante Adams | Raiders | WR | Fresno State | 99 | 45 | 45 | 25 | 63 | 94 | 99 | 6 | 44 | AdamsDavante_10823 | 97 | 99 | 92 | 86 | 73 | 10 | 99 | 48 | 42 | 93 | 24 | 215 | ######## | Default Stride Loose | 95 | Davante | 8 | 97870000 | 63 | 15 | WR | 95 | 26 | 98 | published | Adams | 17 | 22 | 90 | 20 | 96 | 88 | 10 | 18 | 75 | 10 | launch-ratings | 99 | 15 | 10 | 30 | 13 | 45 | 97 | 76 | 85 | 6328 | 25 | Right | 20 | Raiders | 42350000 | 38 | 97 | 25 | 6 | WR_DeepThreat | 52 | 12 | 23 | 95 | Davante Adams | 99 | 17 | 29 | 10823 |
| Myles Garrett | Browns | RE | Texas AM | 98 | 55 | 10 | 17 | 96 | 39 | 21 | 10 | 97 | GarrettMyles_12520 | 8 | 52 | 91 | 40 | 76 | 91 | 25 | 45 | 92 | 88 | 51 | 272 | ######## | Long Stride Default | 4 | Myles | 5 | 84270000 | 36 | 31 | RE | 36 | 94 | 15 | published | Garrett | 95 | 12 | 88 | 45 | 92 | 87 | 23 | 51 | 48 | 98 | launch-ratings | 31 | 84 | 30 | 20 | 45 | 87 | 88 | 55 | 34 | 8560 | 20 | Right | 16 | Browns | 65590000 | 45 | 71 | 44 | 27 | DE_PowerRusher | 90 | 45 | 5 | 85 | Myles Garrett | 99 | 45 | 26 | 12520 |
| Trent Williams | 49ers | LT | Oklahoma | 99 | 12 | 10 | 98 | 98 | 10 | 15 | 6 | 33 | WilliamsTrent_9800 | 5 | 20 | 74 | 10 | 77 | 10 | 51 | 98 | 39 | 87 | 14 | 320 | ######## | Default Stride Awkward | 5 | Trent | 12 | 97870000 | 10 | 6 | LT | 10 | 19 | 15 | published | Williams | 71 | 12 | 76 | 98 | 83 | 98 | 6 | 10 | 10 | 10 | launch-ratings | 15 | 60 | 6 | 10 | 95 | 99 | 88 | 40 | 7 | 3231 | 11 | Right | 14 | 49ers | 40100000 | 93 | 58 | 10 | 6 | OT_Power | 32 | 99 | 15 | 73 | Trent Williams | 99 | 92 | 34 | 9800 |
| Cooper Kupp | Rams | WR | Eastern Wash. | 99 | 59 | 84 | 34 | 66 | 96 | 88 | 38 | 31 | KuppCooper_12558 | 98 | 99 | 96 | 87 | 74 | 10 | 88 | 65 | 31 | 91 | 26 | 208 | ######## | Default | 94 | Cooper | 5 | 89850000 | 55 | 42 | WR | 94 | 22 | 99 | published | Kupp | 10 | 22 | 89 | 32 | 82 | 88 | 40 | 15 | 77 | 10 | launch-ratings | 90 | 26 | 36 | 20 | 39 | 54 | 99 | 76 | 86 | 8626 | 22 | Right | 29 | Rams | 32200000 | 46 | 94 | 10 | 31 | WR_Slot | 28 | 28 | 24 | 95 | Cooper Kupp | 98 | 34 | 29 | 12558 |
| Jalen Ramsey | Rams | CB | Florida State | 98 | 27 | 80 | 22 | 71 | 72 | 55 | 16 | 79 | RamseyJalen_17538 | 24 | 80 | 95 | 69 | 73 | 41 | 70 | 34 | 75 | 88 | 99 | 208 | ######## | Short Stride Default | 12 | Jalen | 6 | 71000000 | 42 | 33 | CB | 78 | 96 | 36 | published | Ramsey | 5 | 34 | 92 | 33 | 94 | 90 | 24 | 98 | 57 | 35 | launch-ratings | 27 | 82 | 26 | 17 | 33 | 65 | 94 | 71 | 68 | 8185 | 18 | Right | 17 | Rams | 43600000 | 21 | 92 | 99 | 21 | CB_MantoMan | 50 | 34 | 24 | 91 | Jalen Ramsey | 98 | 34 | 27 | 17538 |
3.5 HW – Interactive Plots
Submission: Completed qmd file and rendered html file via Canvas.
Overview
These problems apply the idea from the notes ‘3.5 – Interactive Plots’, where we learned how to create interactive plots in R using plotly.
This assignment will visualize some important aspects of NFL players, including physical attributes, positional information and salary. We will be using a dataset of Madden 23 player info. A subset of the madden-23.csv data is shown below:
Assignment
The goal is to recreate some interactive plots with minimal guideance and some plots of your creation in order to understand the structure of plotly function calls. It is designed to be open ended so you can explore a variety of different plot types and interactive plot techniques.
Part a – Scatterplot
Start with a scatterplot visualizing the relationship between overall_rating and totalSalary. Your final plot must consider the following:
- Must be interactive.
- Must take into account overplotting, either by changing the plot type or utilizing additional aesthetics.
- Depending on your implementation of above, can you add additional mouse-over text to add to the plot?
# option 1: alpha blending with plotky
data_madden %>%
plot_ly(x = ~overall_rating,
y = ~(totalSalary),
text = ~`Full Name`) %>%
add_markers(alpha = 0.3)# option 2: hexmap with ggplotly
p <- ggplot(data = data_madden,
aes(x = overall_rating,
y = totalSalary)) +
geom_hex() +
theme_bw()
ggplotly(p)OPTIONAL CHALLENGE:
Use
slice_max()to look at the top 500 players according tooverall_ratingand recreate the following scatterplot / data table setup that can be used during EDA to identify outlying data points.- Try lasso-selecting a few points and seeing the results in the table!
shared_data <- data_madden %>%
slice_max(order_by = overall_rating,
n = 500) %>%
highlight_key()
p <- shared_data %>%
plot_ly(x = ~overall_rating,
y = ~totalSalary) %>%
add_markers(alpha = 0.3) %>%
highlight(on = "plotly_selected")
bscols(p, datatable(shared_data, height = 500))Part b – Dumbell chart
Recreate the following dumbell chart to the best of your ability. Features of this plot:
- Data needs to be pre-summarized to get the average
totalSalaryandsigningBonusbyPosition. Calculate the number of players included in each average calculation as well. - Sorted by increasing average
totalSalary. HINT: This requires amutate()statement, not anarrange()statement. - For each position, the dark green plots the average
totalSalaryand light green adds the averagesigningBonus. Thus we can interpret the ending value as the average total money earned during the first year of the contract. - Well formatted mouse-over interactivity features. HINT: Use html formatting and
scales::comma().
Try to get your plot as close as you can to this plot (with a reasonable amount of effort :)
data_madden %>%
summarize(.by = Position,
across(c(totalSalary, signingBonus), mean),
n = n()) %>%
mutate(Position = fct_reorder(Position, totalSalary)) %>%
plot_ly() %>%
add_segments(x = ~totalSalary,
xend = ~totalSalary + signingBonus,
y = ~Position,
yend = ~Position,
color = I("grey")) %>%
add_markers(x = ~totalSalary,
y = ~Position,
text = ~paste0("Avg salary: $", scales::comma(round(totalSalary, 0)), "<br>Avg signing bonus: $", scales::comma(round(signingBonus, 0)), "<br>Sample size: ", n, " players"),
color = I("darkgreen")) %>%
add_markers(x = ~totalSalary + signingBonus,
y = ~Position,
text = ~paste0("Total money contract year 1: $", scales::comma(round(totalSalary + signingBonus, 0))),
color = I("green")) %>%
layout(title = "Average contract and signing bonus by position",
xaxis = list(title = "Money ($)")) %>%
hide_legend()Part c – Visualize data
Create a mimimum of one additional interactive plot using plot_ly() (not ggplotly()). It can be as simple or complex as you would like. Create additional plots and find a narrative if you wish!